package com.flavors.wan.main.net;

import android.util.ArrayMap;

import com.plat.sdk.okgo.callbck.JsonCallback;
import com.plat.sdk.okgo.net.OKUtils;

import java.util.Map;

/**
 * @author Created by ydong on 2020/1/10 10:32
 * @desc: OKUtils是对OKgo的get 和 post的一个简单封装，这个RequestManager是具体的业务请求类，
 */
public class RequestManager extends OKUtils {

    private static String TAG = "[RequestManager]";

    public static RequestManager getInstance() {
        return InstanceHolder.instance;
    }

    private static class InstanceHolder {
        static final RequestManager instance = new RequestManager();
    }

    public <Bean> void getBannerList(String url, Object tag, Map<String, String> params, JsonCallback<Bean> callback) {
        getRequest(url, tag, params, callback);
    }
    
    public <Bean> void getCoinInfo(String url, Object tag, Map<String, String> params, JsonCallback<Bean> callback) {
        getRequest(url, tag, params, callback);
    }

    /**
     * 登录接口
     *
     * @param url
     * @param tag
     * @param username
     * @param password
     * @param callback
     * @param <Bean>
     */
    public <Bean> void loginClick(String url, Object tag, String username, String password, JsonCallback<Bean> callback) {
        Map<String, String> params = new ArrayMap<>();
        params.put("username", username);
        params.put("password", password);
        postRequest(url, tag, params, callback);
    }

}
